package role

import (
	"context"

	v1 "gitee.com/liangziyisheng/caas-platform-mc/api/role/v1"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/service"
)

func (c *ControllerV1) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoRes, err error) {
	// tenantCode := ctx.Value(consts.TokenClaims.TenantCode).(string)

	res = &v1.InfoRes{Id: req.Id}
	out, err := service.Role().Info(ctx, &v1.InfoInput{Id: req.Id})
	if err != nil {
		return nil, err
	}
	res.Id = out.Id
	res.Name = out.Name
	res.Description = out.Description
	res.Permissions = out.Permissions
	res.Users = out.Users
	res.Menus = out.Menus
	return res, nil
}
